package com.pro.schedule.service.impl;

import com.pro.schedule.entity.EventTypeChild;
import com.pro.schedule.filter.ResultUtil;
import com.pro.schedule.mapper.EventTypeChildMapper;
import com.pro.schedule.service.EventTypeChildService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class EvenTypeChildServiceImpl implements EventTypeChildService {
    @Resource
    ResultUtil resultUtil;
    @Resource
    EventTypeChildMapper eventTypeChildMapper;

    @Override
    public EventTypeChild getEventTypeChildInfo(Integer eventTypeChildId) {
        return eventTypeChildMapper.getEventTypeChildInfo(eventTypeChildId);
    }

    @Override
    public String saveOrUpdateEventTypeChild(EventTypeChild eventTypeChild) throws Exception {
        if (eventTypeChild.getEventTypeChildId() == null) {
            int result = eventTypeChildMapper.insert(eventTypeChild);
            return resultUtil.getResult(result, "保存");
        } else {
            int result = eventTypeChildMapper.updateById(eventTypeChild);
            return resultUtil.getResult(result, "修改");
        }
    }

    @Override
    public String deleteEventTypeChild(Integer eventTypeChildId) throws Exception {
        int result = eventTypeChildMapper.deleteById(eventTypeChildId);
        return resultUtil.getResult(result, "删除");
    }
}
